#pragma once

#include <opencv2\opencv.hpp>

using namespace cv;
using namespace std;

class ANN
{
private:
	CvANN_MLP ann;

	double round(double number)
	{
		return number < 0.0 ? ceil(number - 0.5) : floor(number + 0.5);
	}

public:

	void set_trainer(CvANN_MLP _ann)
	{
		ann = _ann;
	}

	CvANN_MLP get_trainer()
	{
		return ann;
	}

	void create (const Mat& layers)
	{
		ann.create(layers);
	}

	void train(const Mat& data, const Mat& label, const CvANN_MLP_TrainParams& params)
	{
		ann.train(data, label, Mat(), Mat(), params);
	}

	float predict(const Mat& sample)
	{
		cv::Mat response(1, 1, CV_32FC1);

        ann.predict(sample, response);

		return round(response.at<float>(0,0));
	}
};